# -*- coding: utf-8 -*-
# Part of dtcloud. See LICENSE file for full copyright and licensing details.

""" Library-wide configuration variables.

For now, configuration code is in openerp.tools.config. It is in mainly
unprocessed form, e.g. addons_path is a string with commas-separated
paths. The aim is to have code related to configuration (command line
parsing, configuration file loading and saving, ...) in this module
and provide real Python variables, e.g. addons_paths is really a list
of paths.

To initialize properly this module, openerp.tools.config.parse_config()
must be used.

"""

# Paths to search for OpenERP addons.
addons_paths = []

# List of server-wide modules to load. Those modules are supposed to provide
# features not necessarily tied to a particular database. This is in contrast
# to modules that are always bound to a specific database when they are
# installed (i.e. the majority of OpenERP addons). This is set with the --load
# command-line option.
server_wide_modules = []

def find_root_dir():
    import os
    current_dir = os.path.realpath(__file__)

    # dtcloud路径固定，向上遍历目录结构，直到找到根目录
    root_marker = 'dtcloud'
    while not os.path.exists(os.path.join(current_dir, root_marker)):
        # 上移一级目录
        parent_dir = os.path.dirname(current_dir)
        if parent_dir == current_dir:
            raise Exception(f"未找到根目录，因为缺少 '{root_marker}' 标识。")
        current_dir = parent_dir

    return current_dir


SITE_ROOT = find_root_dir()